package com.kunbo.cn.controller.core.customer;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.kunbo.cn.entity.core.customer.CustomerDataPermissions;
import com.kunbo.cn.service.core.customer.CustomerDataPermissionsService;
import com.kunbo.cn.util.retu.BuildBean;
import com.kunbo.cn.util.retu.ResultBean;

/**
 * 客户用户数据权限
 * @author  编写人:刘义
 * @date 时间:2019年3月18日下午6:01:35
 */
@RestController
@RequestMapping("/customerPermissions")
public class CustomerDataPermissionsController {
	
	
	@Autowired
	private CustomerDataPermissionsService service;
	
	
	/**
	 * 新增
	 * @param type
	 * @param typeName
	 * @param customer
	 * @param create_pople
	 * @param project_name
	 * @return
	 */
	@PostMapping("/savePermissions")
	public ResultBean<CustomerDataPermissions> savePermissions(
			@RequestParam("userid")String userid,
			@RequestParam("customerid")Integer customerid,
			@RequestParam("create_pople")Integer create_pople,
			@RequestParam("type")String type
			){
		ResultBean<CustomerDataPermissions> result = new ResultBean<CustomerDataPermissions>();
		return BuildBean.buildResult(result, "success", "error", service.savePermissions(userid,customerid,create_pople,type));
	}
	
	
	/**
	 * 删除
	 * @param id
	 * @return
	 */
	@PostMapping("/delPermissions")
	public ResultBean<Boolean>  delPermissions(
			@RequestParam("id")String id
			){
		ResultBean<Boolean> result = new ResultBean<Boolean>();
		return BuildBean.buildResult(result, "success", "error", service.delPermissions(id));
	}
	
	
	@PostMapping("/selPermissions")
	public ResultBean<List<Map<String,Object>>> selPermissions(
			@RequestParam("userid")String  userid
			){
		ResultBean<List<Map<String,Object>>> result = new ResultBean<List<Map<String,Object>>>();
		return BuildBean.buildResult(result, "success", "error", service.selPermissions(userid));
	}
	
	
	

}
